<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%project_cate}}".
 *
 * @property integer $id
 * @property string $name
 * @property integer $flag
 */
class DhProjectCate extends \common\components\ActiveRecord2015
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%project_cate}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['flag'], 'integer'],
            [['name'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '分类名称',
            'flag' => '是否可用',
        ];
    }

    public static function getCate(){
        $cate = self::find()->where(['flag'=>1])->asArray()->all();
        $cateList = [];
        foreach ($cate as $v){
            $cateList[$v['id']]=$v['name'];
        }
        return $cateList;
    }
}
